#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>

//#include "app.h"

#define UNUSED(x)  ((void)x)

int main(int argc, char*argv[])
{
    //UNUSED(argc);
	//UNUSED(argv);

    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *table;
    GtkWidget *frame;
    gchar *title = "格状测试";

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(window), "delete_event",
                     G_CALLBACK(gtk_main_quit), NULL);
    gtk_window_set_title(GTK_WINDOW(window), title);
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 300);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
     

    frame=gtk_frame_new("请注意下面的按钮排列");
    gtk_container_add(GTK_CONTAINER(window),frame);

    table = gtk_table_new(4,4,FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(table),10);
    gtk_table_set_row_spacings(GTK_TABLE(table),5);
    gtk_table_set_col_spacings(GTK_TABLE(table),5);
    gtk_container_add(GTK_CONTAINER(frame),table);


    button = gtk_button_new_with_label("0,1,0,1");
    gtk_table_attach(GTK_TABLE(table),button,0,1,0,1,GTK_FILL,GTK_FILL,0,0);//0-1,0-1就是第一个格子

    button = gtk_button_new_with_label("1,3,1,3");
    gtk_table_attach(GTK_TABLE(table),button,1,3,1,3,GTK_FILL,GTK_FILL,0,0);//实际上是占了横向的第2和3的格子,纵向第2和3的格子

    button = gtk_button_new_with_label("0,1,1,3");
    gtk_table_attach(GTK_TABLE(table),button,0,1,1,3,GTK_FILL,GTK_FILL,0,0);//0-1,1-3

    button = gtk_button_new_with_label("1,3,0,1");
    gtk_table_attach_defaults(GTK_TABLE(table),button,1,3,0,1);//1-3,0-1

    button = gtk_button_new_with_label("0,4,3,4");
    gtk_table_attach_defaults(GTK_TABLE(table),button,0,4,3,4);//0-4,3-4

    button = gtk_button_new_with_label("3,4,0,3");
    gtk_table_attach_defaults(GTK_TABLE(table),button,3,4,0,3);//3-4,0-3
    gtk_widget_show_all(window);

    gtk_widget_show_all(window);

    gtk_main();
    /* int ret = 0;
    struct app *p_app = NULL;

    p_app = (struct app *)malloc(sizeof(struct app));

    ret = sigsetjmp(p_app->ctrl_c_jump, 1);
    if (ret != 2) {
        init(p_app);  
        run(p_app);
    }

    destroy(p_app); */

    return 0;
}